package cn.chenhuanming.shh.administer.utils;

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.IdentifierGenerator;

import java.io.Serializable;
import java.util.UUID;

/**
 * Created by chenhuanming on 2017-07-31.
 *
 * @author chenhuanming
 */
public class IDGenerator implements IdentifierGenerator {

    @Override
    public Serializable generate(SessionImplementor session, Object object) throws HibernateException {
        return UUID.randomUUID().toString().replaceAll("-","").substring(16);
    }
}
